﻿@{
    Layout = null;
}

<div>
    <div class="col-3 pr-0" style="display: none">
        <label id="SampleBatch-Parent-ModalID">@ViewData["ModalID"]</label>
        <label id="SampleBatch-SampleBatchId">@ViewData["SampleBatchId"]</label>
    </div>
    <div class="input-group">
        <div class="col-3 pr-0 pl-0">
            <span class="input-group-text font-rfs border-radius-noright noRightBorder">批次号</span>
        </div>
        <div class="col-9 pl-0 pr-0 input-group">
            <input id="SampleBatch-Batch" class="form-control font-rfs border-radius-noleft border-radius-noright" onchange="CheckBatch(this)" style="width:90%;"/>
            <span class="input-group-text font-rfs border-radius-noleft noLeftBorder" style="width:10%">
                <i id="check" class="bi-check-circle-fill"></i>
            </span>
        </div>
    </div>
    <div class="input-group">
        <div class="col-3 pr-0 pl-0">
            <span class="input-group-text font-rfs border-radius-noright noRightBorder">Ex1</span>
        </div>
        <div class="col-9 pl-0" style="padding-right: 0px;">
            <input id="SampleBatch-Ex1" class="form-control font-rfs border-radius-noleft border-radius-noright" />
        </div>
    </div>
    <div class="input-group">
        <div class="col-3 pr-0 pl-0">
            <span class="input-group-text font-rfs border-radius-noright noRightBorder">Ex2</span>
        </div>
        <div class="col-9 pl-0" style="padding-right: 0px;">
            <input id="SampleBatch-Ex2" class="form-control font-rfs border-radius-noleft border-radius-noright" />
        </div>
    </div>
    <div class="input-group">
        <div class="col-3 pr-0 pl-0">
            <span class="input-group-text font-rfs border-radius-noright noRightBorder">Ex3</span>
        </div>
        <div class="col-9 pl-0" style="padding-right: 0px;">
            <input id="SampleBatch-Ex3" class="form-control font-rfs border-radius-noleft border-radius-noright" />
        </div>
    </div>
    <div class="input-group">
        <div class="col-3 pr-0 pl-0">
            <span class="input-group-text font-rfs border-radius-noright noRightBorder">送样单位/部门</span>
        </div>
        <div class="col-9 pl-0" style="padding-right: 0px;">
            <input id="SampleBatch-SendDepartment" class="form-control font-rfs border-radius-noleft border-radius-noright" />
        </div>
    </div>
    <div class="input-group">
        <div class="col-3 pr-0 pl-0">
            <span class="input-group-text font-rfs border-radius-noright noRightBorder">送样人</span>
        </div>
        <div class="col-9 pl-0" style="padding-right: 0px;">
            <input id="SampleBatch-SendPerson" class="form-control font-rfs border-radius-noleft border-radius-noright" />
        </div>
    </div>
    <div class="input-group">
        <div class="col-3 pr-0 pl-0">
            <span class="input-group-text font-rfs border-radius-noright noRightBorder">送样时间</span>
        </div>
        <div class="col-9 pl-0" style="padding-right: 0px;">
            <input id="SampleBatch-SendTime" class="TimePicker form-control font-rfs border-radius-noleft border-radius-noright" />
        </div>
    </div>
</div>
<div class="text-right" style="padding-top: 5px;">
    <button id="SampleBatch-confirm" type="button" class="btn btn-primary font-rfs">确定</button>
    <button id="SampleBatch-cancel" type="button" class="btn btn-info font-rfs">取消</button>
</div>

<script>

    $(document).ready(function () {
        $("#SampleBatch-Batch").val($("#SampleBatch-SampleBatchId").html());
        CheckSampleBatch($("#SampleBatch-SampleBatchId").html());

        $('.TimePicker').datetimepicker({
            timepicker: true,
            format: "Y/m/d H:i"
        });
        $.datetimepicker.setLocale('zh');

    });

    function CheckSampleBatch(batchid) {
        $.post("CheckSampleBatch", {
            BatchId: batchid
        }, function (data) {
            if (data == true) {
                $("#check").css('color', 'tomato');
                $('#SampleBatch-confirm').attr('disabled', 'disabled');
            } else {
                $("#check").css('color', 'forestgreen');
                $('#SampleBatch-confirm').removeAttr('disabled');
            }
        });
    }

    function CheckBatch(obj) {
        CheckSampleBatch($(obj).val());
    }

    $("#SampleBatch-confirm").click(function () {
        var jsonStr = {};
        jsonStr["BatchId"] = $('#SampleBatch-Batch').val();
        jsonStr["Ex1"] = $('#SampleBatch-Ex1').val();
        jsonStr["Ex2"] = $('#SampleBatch-Ex2').val();
        jsonStr["Ex3"] = $('#SampleBatch-Ex3').val();
        jsonStr["SendDepartment"] = $('#SampleBatch-SendDepartment').val();
        jsonStr["SendPerson"] = $('#SampleBatch-SendPerson').val();
        jsonStr["SendTime"] = $('#SampleBatch-SendTime').val();

        $.post("AddSampleBatch", {
            jsonStr: JSON.stringify(jsonStr)
        }, function (data) {
            if (data.indexOf("成功") >= 0) {
                $("#SampleBatch-cancel").click();
            } else {
                alert(data);
            }
        });
    });

    $("#SampleBatch-cancel").click(function () {
        var modalID = $("#SampleBatch-Parent-ModalID").html();
        $("#" + modalID).modal('hide');
    });

</script>
